|
|
|
|
|
|
|
Another optional property is CopiesToPrinter. This property enables you to print multiple copies of your report easily at one time. You can set this property to any integer value. |
|
|
|
|
|
|
|
|
The final property you might need to set at runtime is DataFiles. This property is not available at designtime. It specifies the name of the database file to be used with the report. Now you might be thinking, "I told the report what file to use when I created it." That is true, but when you created the report, the database file was stored with a path based on your directory structure. And your path might not be the same as the directory structure of your users. |
|
|
|
|
|
|
|
|
The DataFiles property is actually an array with the first element number of 0. If you're using more than one database in your report, you need to set the value of each DataFiles array element. For most of your reports, however, you will be using only a single database. The following line of code shows you how to set the value of the DataFiles property for the database; this line assumes that the database file is in the same folder as your application: |
|
|
|
|
|
|
|
|
rptMember.DataFiles(0) = App.Path & "\Members.mdb" |
|
|
|
|
|
|
|
|
Even after you add the Crystal Reports control to your form and set its properties, you still have to tell Crystal Reports when to print or display the report by adding a line of code. The report then prints using the report file and other properties that you set. If you have your report set up to preview onscreen, it appears in a window similar to the one shown in Figure 29.18. The following line of code uses the PrintReport method to run a report: |
|
|
|
|
|
|
|
|
CrystalReport1.PrintReport |
|
|
|
|
|
|
|
|
Note that even though the name of the method is PrintReport, it is sent to the destination you specified earlier. |
|
|
|
|
|
|
|
|
|
You can also print a report by setting the Action property of the Crystal Reports control to 1.  |
|
|
|
|
|
|
|
|
|
|
Figure 29.18
The desired report has been printed to the screen. |
|
|
|
|
|